<?php
namespace app\fruit\controller;
use app\common\Base;
use think\Db;

class GroupFruitQuery extends Base {
	
	public function index() {
		return $this->fetch();
	}

	public function pageQuery() {
		$where = [];
		if(input("termId")) $where["学期ID"] = input("termId");
		if(input("获奖级别")) $where["获奖级别"] = input("获奖级别");
		if(input("获奖等第")) $where["获奖等第"] = input("获奖等第");
		if(input("授奖对象")) $where["授奖对象"] = array("like",input("授奖对象"));
		$page = input("page");
		$rows = input("rows");
		$result = Db::table('集体成果')->alias('a')
				  ->join('学期名称 b','a.学期ID = b.ID','LEFT')
				  ->field("a.ID,a.学期ID,a.获奖时间,a.授奖对象,a.荣誉称号,a.获奖级别,a.获奖等第,a.授奖单位,a.备注,b.学期名称")
				  ->where($where)
				  ->order("学期ID desc,ID desc")
				  ->page($page, $rows)
		          ->select();
		$count = Db::table('集体成果')->alias('a')
				  ->join('学期名称 b','a.学期ID = b.ID','LEFT')
				  ->where($where)
				  ->count();
		$grid['rows'] = selectResult($result);
        $grid['total'] = $count;
		return $grid;
	}

}
